package com.xiaocz.hblsubstitutedriving.adapter;

import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.TextView;

import com.xiaocz.common.widgets.recycler.RecyclerViewAdapter;
import com.xiaocz.hblsubstitutedriving.R;
import com.xiaocz.hblsubstitutedriving.model.OrderPrice;


/**
 * Author:  xiaocz.
 * Date:    2018/05.04.
 * Descr:  计价标准
 */
public class ExpenseStandardListAdapter extends RecyclerViewAdapter<OrderPrice> {

    public ExpenseStandardListAdapter(AdapterListener<OrderPrice> adapterListener) {
        super(adapterListener);
    }

    @Override
    protected int getItemViewType(int position, OrderPrice data) {
        return R.layout.item_expense_standard_list;
    }

    @Override
    protected ViewHolder<OrderPrice> getViewHolder(View view, int viewType) {
        return new InfoTypeViewHolder(view);
    }

    private static class InfoTypeViewHolder extends ViewHolder<OrderPrice> {

        private TextView tvTitle, tvInfo;

        public InfoTypeViewHolder(View itemView) {
            super(itemView);
            tvTitle = itemView.findViewById(R.id.info_title);
            tvInfo = itemView.findViewById(R.id.tv_info);
        }

        @Override
        protected void onBind(OrderPrice data, int position) {
            tvTitle.setText(String.valueOf(mContext.getResources().getStringArray(R.array.expense_standard)[position]+"("+data.getQishitime()+"-"+data.getJieshutime()+")"));
            tvInfo.setText(String.valueOf(data.getQibukm()+"公里起步价"+data.getQibuprice()+"元，超出后每"+data.getChaokm()+"公里加收"+data.getChaochuprice()+"元"));
        }

        @Override
        public boolean isNeedClick() {
            return true;
        }
    }
}